import React from 'react';
import './index.less';
import { Form, Input } from 'antd';
import RichText from '@/components/editor';

/**
 * 导出组件
 */
export default React.forwardRef((props, ref) => {
  const { formFileds = [], isDisabled = false, otherProps } = props || {};
  return (
    <React.Fragment>
      <Form layout="inline" ref={ref} {...otherProps}>
        {/* { formFileds.map((item, index)=>buildFormItem(item, index, isDisabled)) } */}
        {formFileds.map((item, index) => {
          const elType = item.formElement['el-type'];
          return (
            <Form.Item {...item.formItem} key={index}>
              {elType == 'md' ? (
                <RichText disabled={isDisabled} {...item.formElement} />
              ) : (
                <Input disabled={isDisabled} {...item.formElement} />
              )}
            </Form.Item>
          );
        })}
      </Form>
    </React.Fragment>
  );
});
